package com.example.mywechat;


import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;


public class frdFragment extends Fragment{




    private List<friendbean> list = new ArrayList<>();
    private  void initView(View view){

        initfriend();
        //找到RecyclerView控件

        RecyclerView recyclerView = view.findViewById(R.id.friendrecycler_view);
        //布局管理器
        LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
        recyclerView.setLayoutManager(layoutManager);
        friendadaptor adapter = new friendadaptor(list);//适配器对象
        recyclerView.setAdapter(adapter);//设置适配器为上面的对象



    }









    private void initfriend(){
        friendbean friendbean=new friendbean("同学",R.drawable.friend);
        list.add(friendbean);

        friendbean friendbean1=new friendbean("小胖",R.drawable.friend1);
        list.add(friendbean1);

        friendbean friendbean2=new friendbean("大胖",R.drawable.friend2);
        list.add(friendbean2);


        friendbean friendbean5=new friendbean("朋友",R.drawable.friend5);
        list.add(friendbean5);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.tab02, container, false);
        initView(view);
        return view;
    }
}